#include "ast.hpp"
#include "catch2/catch.hpp"
#include "lexer.hpp"
#include "parser.hpp"
#include "symtable.hpp"

TEST_CASE("if statement") {
    auto code = R"gal(
        if (1 < 2) {
            print(0);
        }
    )gal";
    SymbolTable::builtin_symtable->load_builtin();
    SymbolTable symtable(SymbolTable::builtin_symtable);

    auto parser = Parser(Lexer::from_string(code), &symtable);
    auto node = parser.parse();
    REQUIRE(node != nullptr);
    auto stmt = dynamic_cast<ListNode*>(node);
    REQUIRE(stmt != nullptr);
    REQUIRE(stmt->node_list()->size() == 1);
    auto if_node = dynamic_cast<IfNode*>(stmt->node_list()->front());
    CHECK(if_node != nullptr);
}
